home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / js / jsobj.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  20KB  |  500 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  * vim: set ts=8 sw=4 et tw=80:
  3.  *
  4.  * ***** BEGIN LICENSE BLOCK *****
  5.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6.  *
  7.  * The contents of this file are subject to the Mozilla Public License Version
  8.  * 1.1 (the "License"); you may not use this file except in compliance with
  9.  * the License. You may obtain a copy of the License at
  10.  * http://www.mozilla.org/MPL/
  11.  *
  12.  * Software distributed under the License is distributed on an "AS IS" basis,
  13.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14.  * for the specific language governing rights and limitations under the
  15.  * License.
  16.  *
  17.  * The Original Code is Mozilla Communicator client code, released
  18.  * March 31, 1998.
  19.  *
  20.  * The Initial Developer of the Original Code is
  21.  * Netscape Communications Corporation.
  22.  * Portions created by the Initial Developer are Copyright (C) 1998
  23.  * the Initial Developer. All Rights Reserved.
  24.  *
  25.  * Contributor(s):
  26.  *
  27.  * Alternatively, the contents of this file may be used under the terms of
  28.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  29.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30.  * in which case the provisions of the GPL or the LGPL are applicable instead
  31.  * of those above. If you wish to allow use of your version of this file only
  32.  * under the terms of either the GPL or the LGPL, and not to allow others to
  33.  * use your version of this file under the terms of the MPL, indicate your
  34.  * decision by deleting the provisions above and replace them with the notice
  35.  * and other provisions required by the GPL or the LGPL. If you do not delete
  36.  * the provisions above, a recipient may use your version of this file under
  37.  * the terms of any one of the MPL, the GPL or the LGPL.
  38.  *
  39.  * ***** END LICENSE BLOCK ***** */
  40.  
  41. #ifndef jsobj_h___
  42. #define jsobj_h___
  43. /*
  44.  * JS object definitions.
  45.  *
  46.  * A JS object consists of a possibly-shared object descriptor containing
  47.  * ordered property names, called the map; and a dense vector of property
  48.  * values, called slots.  The map/slot pointer pair is GC'ed, while the map
  49.  * is reference counted and the slot vector is malloc'ed.
  50.  */
  51. #include "jshash.h" /* Added by JSIFY */
  52. #include "jsprvtd.h"
  53. #include "jspubtd.h"
  54.  
  55. JS_BEGIN_EXTERN_C
  56.  
  57. struct JSObjectMap {
  58.     jsrefcount  nrefs;          /* count of all referencing objects */
  59.     JSObjectOps *ops;           /* high level object operation vtable */
  60.     uint32      nslots;         /* length of obj->slots vector */
  61.     uint32      freeslot;       /* index of next free obj->slots element */
  62. };
  63.  
  64. /* Shorthand macros for frequently-made calls. */
  65. #define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp)                             \
  66.     (obj)->map->ops->lookupProperty(cx,obj,id,objp,propp)
  67. #define OBJ_DEFINE_PROPERTY(cx,obj,id,value,getter,setter,attrs,propp)        \
  68.     (obj)->map->ops->defineProperty(cx,obj,id,value,getter,setter,attrs,propp)
  69. #define OBJ_GET_PROPERTY(cx,obj,id,vp)                                        \
  70.     (obj)->map->ops->getProperty(cx,obj,id,vp)
  71. #define OBJ_SET_PROPERTY(cx,obj,id,vp)                                        \
  72.     (obj)->map->ops->setProperty(cx,obj,id,vp)
  73. #define OBJ_GET_ATTRIBUTES(cx,obj,id,prop,attrsp)                             \
  74.     (obj)->map->ops->getAttributes(cx,obj,id,prop,attrsp)
  75. #define OBJ_SET_ATTRIBUTES(cx,obj,id,prop,attrsp)                             \
  76.     (obj)->map->ops->setAttributes(cx,obj,id,prop,attrsp)
  77. #define OBJ_DELETE_PROPERTY(cx,obj,id,rval)                                   \
  78.     (obj)->map->ops->deleteProperty(cx,obj,id,rval)
  79. #define OBJ_DEFAULT_VALUE(cx,obj,hint,vp)                                     \
  80.     (obj)->map->ops->defaultValue(cx,obj,hint,vp)
  81. #define OBJ_ENUMERATE(cx,obj,enum_op,statep,idp)                              \
  82.     (obj)->map->ops->enumerate(cx,obj,enum_op,statep,idp)
  83. #define OBJ_CHECK_ACCESS(cx,obj,id,mode,vp,attrsp)                            \
  84.     (obj)->map->ops->checkAccess(cx,obj,id,mode,vp,attrsp)
  85.  
  86. /* These four are time-optimized to avoid stub calls. */
  87. #define OBJ_THIS_OBJECT(cx,obj)                                               \
  88.     ((obj)->map->ops->thisObject                                              \
  89.      ? (obj)->map->ops->thisObject(cx,obj)                                    \
  90.      : (obj))
  91. #define OBJ_DROP_PROPERTY(cx,obj,prop)                                        \
  92.     ((obj)->map->ops->dropProperty                                            \
  93.      ? (obj)->map->ops->dropProperty(cx,obj,prop)                             \
  94.      : (void)0)
  95. #define OBJ_GET_REQUIRED_SLOT(cx,obj,slot)                                    \
  96.     ((obj)->map->ops->getRequiredSlot                                         \
  97.      ? (obj)->map->ops->getRequiredSlot(cx, obj, slot)                        \
  98.      : JSVAL_VOID)
  99. #define OBJ_SET_REQUIRED_SLOT(cx,obj,slot,v)                                  \
  100.     ((obj)->map->ops->setRequiredSlot                                         \
  101.      ? (obj)->map->ops->setRequiredSlot(cx, obj, slot, v)                     \
  102.      : JS_TRUE)
  103.  
  104. #define OBJ_TO_INNER_OBJECT(cx,obj)                                           \
  105.     JS_BEGIN_MACRO                                                            \
  106.         JSClass *clasp_ = OBJ_GET_CLASS(cx, obj);                             \
  107.         if (clasp_->flags & JSCLASS_IS_EXTENDED) {                            \
  108.             JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_;              \
  109.             if (xclasp_->innerObject)                                         \
  110.                 obj = xclasp_->innerObject(cx, obj);                          \
  111.         }                                                                     \
  112.     JS_END_MACRO
  113.  
  114. /*
  115.  * In the original JS engine design, obj->slots pointed to a vector of length
  116.  * JS_INITIAL_NSLOTS words if obj->map was shared with a prototype object,
  117.  * else of length obj->map->nslots.  With the advent of JS_GetReservedSlot,
  118.  * JS_SetReservedSlot, and JSCLASS_HAS_RESERVED_SLOTS (see jsapi.h), the size
  119.  * of the minimum length slots vector in the case where map is shared cannot
  120.  * be constant.  This length starts at JS_INITIAL_NSLOTS, but may advance to
  121.  * include all the reserved slots.
  122.  *
  123.  * Therefore slots must be self-describing.  Rather than tag its low order bit
  124.  * (a bit is all we need) to distinguish initial length from reserved length,
  125.  * we do "the BSTR thing": over-allocate slots by one jsval, and store the
  126.  * *net* length (counting usable slots, which have non-negative obj->slots[]
  127.  * indices) in obj->slots[-1].  All code that sets obj->slots must be aware of
  128.  * this hack -- you have been warned, and jsobj.c has been updated!
  129.  */
  130. struct JSObject {
  131.     JSObjectMap *map;
  132.     jsval       *slots;
  133. };
  134.  
  135. #define JSSLOT_PROTO        0
  136. #define JSSLOT_PARENT       1
  137. #define JSSLOT_CLASS        2
  138. #define JSSLOT_PRIVATE      3
  139. #define JSSLOT_START(clasp) (((clasp)->flags & JSCLASS_HAS_PRIVATE)           \
  140.                              ? JSSLOT_PRIVATE + 1                             \
  141.                              : JSSLOT_CLASS + 1)
  142.  
  143. #define JSSLOT_FREE(clasp)  (JSSLOT_START(clasp)                              \
  144.                              + JSCLASS_RESERVED_SLOTS(clasp))
  145.  
  146. #define JS_INITIAL_NSLOTS   5
  147.  
  148. #ifdef DEBUG
  149. #define MAP_CHECK_SLOT(map,slot) \
  150.     JS_ASSERT((uint32)slot < JS_MIN((map)->freeslot, (map)->nslots))
  151. #define OBJ_CHECK_SLOT(obj,slot) \
  152.     MAP_CHECK_SLOT((obj)->map, slot)
  153. #else
  154. #define OBJ_CHECK_SLOT(obj,slot) ((void)0)
  155. #endif
  156.  
  157. /* Fast macros for accessing obj->slots while obj is locked (if thread-safe). */
  158. #define LOCKED_OBJ_GET_SLOT(obj,slot) \
  159.     (OBJ_CHECK_SLOT(obj, slot), (obj)->slots[slot])
  160. #define LOCKED_OBJ_SET_SLOT(obj,slot,value) \
  161.     (OBJ_CHECK_SLOT(obj, slot), (obj)->slots[slot] = (value))
  162. #define LOCKED_OBJ_GET_PROTO(obj) \
  163.     JSVAL_TO_OBJECT(LOCKED_OBJ_GET_SLOT(obj, JSSLOT_PROTO))
  164. #define LOCKED_OBJ_GET_CLASS(obj) \
  165.     ((JSClass *)JSVAL_TO_PRIVATE(LOCKED_OBJ_GET_SLOT(obj, JSSLOT_CLASS)))
  166.  
  167. #ifdef JS_THREADSAFE
  168.  
  169. /* Thread-safe functions and wrapper macros for accessing obj->slots. */
  170. #define OBJ_GET_SLOT(cx,obj,slot)                                             \
  171.     (OBJ_CHECK_SLOT(obj, slot),                                               \
  172.      (OBJ_IS_NATIVE(obj) && OBJ_SCOPE(obj)->ownercx == cx)                    \
  173.      ? LOCKED_OBJ_GET_SLOT(obj, slot)                                         \
  174.      : js_GetSlotThreadSafe(cx, obj, slot))
  175.  
  176. #define OBJ_SET_SLOT(cx,obj,slot,value)                                       \
  177.     (OBJ_CHECK_SLOT(obj, slot),                                               \
  178.      (OBJ_IS_NATIVE(obj) && OBJ_SCOPE(obj)->ownercx == cx)                    \
  179.      ? (void) LOCKED_OBJ_SET_SLOT(obj, slot, value)                           \
  180.      : js_SetSlotThreadSafe(cx, obj, slot, value))
  181.  
  182. /*
  183.  * If thread-safe, define an OBJ_GET_SLOT wrapper that bypasses, for a native
  184.  * object, the lock-free "fast path" test of (OBJ_SCOPE(obj)->ownercx == cx),
  185.  * to avoid needlessly switching from lock-free to lock-full scope when doing
  186.  * GC on a different context from the last one to own the scope.  The caller
  187.  * in this case is probably a JSClass.mark function, e.g., fun_mark, or maybe
  188.  * a finalizer.
  189.  *
  190.  * The GC runs only when all threads except the one on which the GC is active
  191.  * are suspended at GC-safe points, so there is no hazard in directly accessing
  192.  * obj->slots[slot] from the GC's thread, once rt->gcRunning has been set.  See
  193.  * jsgc.c for details.
  194.  */
  195. #define THREAD_IS_RUNNING_GC(rt, thread)                                      \
  196.     ((rt)->gcRunning && (rt)->gcThread == (thread))
  197.  
  198. #define CX_THREAD_IS_RUNNING_GC(cx)                                           \
  199.     THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread)
  200.  
  201. #define GC_AWARE_GET_SLOT(cx, obj, slot)                                      \
  202.     ((OBJ_IS_NATIVE(obj) && CX_THREAD_IS_RUNNING_GC(cx))                      \
  203.      ? (obj)->slots[slot]                                                     \
  204.      : OBJ_GET_SLOT(cx, obj, slot))
  205.  
  206. #else   /* !JS_THREADSAFE */
  207.  
  208. #define OBJ_GET_SLOT(cx,obj,slot)       LOCKED_OBJ_GET_SLOT(obj,slot)
  209. #define OBJ_SET_SLOT(cx,obj,slot,value) LOCKED_OBJ_SET_SLOT(obj,slot,value)
  210. #define GC_AWARE_GET_SLOT(cx,obj,slot)  LOCKED_OBJ_GET_SLOT(obj,slot)
  211.  
  212. #endif /* !JS_THREADSAFE */
  213.  
  214. /* Thread-safe proto, parent, and class access macros. */
  215. #define OBJ_GET_PROTO(cx,obj) \
  216.     JSVAL_TO_OBJECT(OBJ_GET_SLOT(cx, obj, JSSLOT_PROTO))
  217. #define OBJ_SET_PROTO(cx,obj,proto) \
  218.     OBJ_SET_SLOT(cx, obj, JSSLOT_PROTO, OBJECT_TO_JSVAL(proto))
  219.  
  220. #define OBJ_GET_PARENT(cx,obj) \
  221.     JSVAL_TO_OBJECT(OBJ_GET_SLOT(cx, obj, JSSLOT_PARENT))
  222. #define OBJ_SET_PARENT(cx,obj,parent) \
  223.     OBJ_SET_SLOT(cx, obj, JSSLOT_PARENT, OBJECT_TO_JSVAL(parent))
  224.  
  225. #define OBJ_GET_CLASS(cx,obj) \
  226.     ((JSClass *)JSVAL_TO_PRIVATE(OBJ_GET_SLOT(cx, obj, JSSLOT_CLASS)))
  227.  
  228. /* Test whether a map or object is native. */
  229. #define MAP_IS_NATIVE(map)                                                    \
  230.     ((map)->ops == &js_ObjectOps ||                                           \
  231.      ((map)->ops && (map)->ops->newObjectMap == js_ObjectOps.newObjectMap))
  232.  
  233. #define OBJ_IS_NATIVE(obj)  MAP_IS_NATIVE((obj)->map)
  234.  
  235. extern JS_FRIEND_DATA(JSObjectOps) js_ObjectOps;
  236. extern JS_FRIEND_DATA(JSObjectOps) js_WithObjectOps;
  237. extern JSClass  js_ObjectClass;
  238. extern JSClass  js_WithClass;
  239.  
  240. struct JSSharpObjectMap {
  241.     jsrefcount  depth;
  242.     jsatomid    sharpgen;
  243.     JSHashTable *table;
  244. };
  245.  
  246. #define SHARP_BIT       ((jsatomid) 1)
  247. #define BUSY_BIT        ((jsatomid) 2)
  248. #define SHARP_ID_SHIFT  2
  249. #define IS_SHARP(he)    (JS_PTR_TO_UINT32((he)->value) & SHARP_BIT)
  250. #define MAKE_SHARP(he)  ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|SHARP_BIT))
  251. #define IS_BUSY(he)     (JS_PTR_TO_UINT32((he)->value) & BUSY_BIT)
  252. #define MAKE_BUSY(he)   ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|BUSY_BIT))
  253. #define CLEAR_BUSY(he)  ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)&~BUSY_BIT))
  254.  
  255. extern JSHashEntry *
  256. js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
  257.                     jschar **sp);
  258.  
  259. extern void
  260. js_LeaveSharpObject(JSContext *cx, JSIdArray **idap);
  261.  
  262. extern JSBool
  263. js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  264.                 jsval *rval);
  265.  
  266. extern JSBool
  267. js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  268.                 jsval *rval);
  269.  
  270. extern JSBool
  271. js_HasOwnPropertyHelper(JSContext *cx, JSObject *obj, JSLookupPropOp lookup,
  272.                         uintN argc, jsval *argv, jsval *rval);
  273.  
  274. extern JSObject *
  275. js_InitObjectClass(JSContext *cx, JSObject *obj);
  276.  
  277. /* Select Object.prototype method names shared between jsapi.c and jsobj.c. */
  278. extern const char js_watch_str[];
  279. extern const char js_unwatch_str[];
  280. extern const char js_hasOwnProperty_str[];
  281. extern const char js_isPrototypeOf_str[];
  282. extern const char js_propertyIsEnumerable_str[];
  283. extern const char js_defineGetter_str[];
  284. extern const char js_defineSetter_str[];
  285. extern const char js_lookupGetter_str[];
  286. extern const char js_lookupSetter_str[];
  287.  
  288. extern void
  289. js_InitObjectMap(JSObjectMap *map, jsrefcount nrefs, JSObjectOps *ops,
  290.                  JSClass *clasp);
  291.  
  292. extern JSObjectMap *
  293. js_NewObjectMap(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops,
  294.                 JSClass *clasp, JSObject *obj);
  295.  
  296. extern void
  297. js_DestroyObjectMap(JSContext *cx, JSObjectMap *map);
  298.  
  299. extern JSObjectMap *
  300. js_HoldObjectMap(JSContext *cx, JSObjectMap *map);
  301.  
  302. extern JSObjectMap *
  303. js_DropObjectMap(JSContext *cx, JSObjectMap *map, JSObject *obj);
  304.  
  305. extern JSObject *
  306. js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent);
  307.  
  308. extern JSBool
  309. js_FindConstructor(JSContext *cx, JSObject *start, const char *name, jsval *vp);
  310.  
  311. extern JSObject *
  312. js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,
  313.                    JSObject *parent, uintN argc, jsval *argv);
  314.  
  315. extern void
  316. js_FinalizeObject(JSContext *cx, JSObject *obj);
  317.  
  318. extern JSBool
  319. js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp);
  320.  
  321. extern void
  322. js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot);
  323.  
  324. /*
  325.  * Native property add and lookup variants that hide id in the hidden atom
  326.  * subspace, so as to avoid collisions between internal properties such as
  327.  * formal arguments and local variables in function objects, and externally
  328.  * set properties with the same ids.
  329.  */
  330. extern JSScopeProperty *
  331. js_AddHiddenProperty(JSContext *cx, JSObject *obj, jsid id,
  332.                      JSPropertyOp getter, JSPropertyOp setter, uint32 slot,
  333.                      uintN attrs, uintN flags, intN shortid);
  334.  
  335. extern JSBool
  336. js_LookupHiddenProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
  337.                         JSProperty **propp);
  338.  
  339. /*
  340.  * Find or create a property named by id in obj's scope, with the given getter
  341.  * and setter, slot, attributes, and other members.
  342.  */
  343. extern JSScopeProperty *
  344. js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id,
  345.                      JSPropertyOp getter, JSPropertyOp setter, uint32 slot,
  346.                      uintN attrs, uintN flags, intN shortid);
  347.  
  348. /*
  349.  * Change sprop to have the given attrs, getter, and setter in scope, morphing
  350.  * it into a potentially new JSScopeProperty.  Return a pointer to the changed
  351.  * or identical property.
  352.  */
  353. extern JSScopeProperty *
  354. js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj,
  355.                              JSScopeProperty *sprop, uintN attrs, uintN mask,
  356.                              JSPropertyOp getter, JSPropertyOp setter);
  357.  
  358. /*
  359.  * On error, return false.  On success, if propp is non-null, return true with
  360.  * obj locked and with a held property in *propp; if propp is null, return true
  361.  * but release obj's lock first.  Therefore all callers who pass non-null propp
  362.  * result parameters must later call OBJ_DROP_PROPERTY(cx, obj, *propp) both to
  363.  * drop the held property, and to release the lock on obj.
  364.  */
  365. extern JSBool
  366. js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
  367.                   JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
  368.                   JSProperty **propp);
  369.  
  370. extern JSBool
  371. js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
  372.                         JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
  373.                         uintN flags, intN shortid, JSProperty **propp);
  374.  
  375. /*
  376.  * Unlike js_DefineProperty, propp must be non-null.  On success, and if id was
  377.  * found, return true with *objp non-null and locked, and with a held property
  378.  * stored in *propp.  If successful but id was not found, return true with both
  379.  * *objp and *propp null.  Therefore all callers who receive a non-null *propp
  380.  * must later call OBJ_DROP_PROPERTY(cx, *objp, *propp).
  381.  */
  382. extern JS_FRIEND_API(JSBool)
  383. js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
  384.                   JSProperty **propp);
  385.  
  386. /*
  387.  * Specialized subroutine that allows caller to preset JSRESOLVE_* flags.
  388.  */
  389. extern JSBool
  390. js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
  391.                            JSObject **objp, JSProperty **propp);
  392.  
  393. extern JS_FRIEND_API(JSBool)
  394. js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp,
  395.                 JSProperty **propp);
  396.  
  397. extern JSObject *
  398. js_FindIdentifierBase(JSContext *cx, jsid id);
  399.  
  400. extern JSObject *
  401. js_FindVariableScope(JSContext *cx, JSFunction **funp);
  402.  
  403. extern JSBool
  404. js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
  405.  
  406. extern JSBool
  407. js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
  408.  
  409. extern JSBool
  410. js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
  411.                  uintN *attrsp);
  412.  
  413. extern JSBool
  414. js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
  415.                  uintN *attrsp);
  416.  
  417. extern JSBool
  418. js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval);
  419.  
  420. extern JSBool
  421. js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp);
  422.  
  423. extern JSIdArray *
  424. js_NewIdArray(JSContext *cx, jsint length);
  425.  
  426. /*
  427.  * Unlike realloc(3), this function frees ida on failure.
  428.  */
  429. extern JSIdArray *
  430. js_SetIdArrayLength(JSContext *cx, JSIdArray *ida, jsint length);
  431.  
  432. extern JSBool
  433. js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
  434.              jsval *statep, jsid *idp);
  435.  
  436. extern JSBool
  437. js_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
  438.                jsval *vp, uintN *attrsp);
  439.  
  440. extern JSBool
  441. js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
  442.  
  443. extern JSBool
  444. js_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  445.              jsval *rval);
  446.  
  447. extern JSBool
  448. js_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
  449.  
  450. extern JSBool
  451. js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj);
  452.  
  453. extern JSBool
  454. js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
  455.  
  456. extern JSBool
  457. js_GetClassPrototype(JSContext *cx, const char *name, JSObject **protop);
  458.  
  459. extern JSBool
  460. js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto,
  461.                      uintN attrs);
  462.  
  463. extern JSBool
  464. js_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
  465.  
  466. extern JSObject *
  467. js_ValueToNonNullObject(JSContext *cx, jsval v);
  468.  
  469. extern JSBool
  470. js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval);
  471.  
  472. extern JSBool
  473. js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
  474.              uintN argc, jsval *argv, jsval *rval);
  475.  
  476. extern JSBool
  477. js_XDRObject(JSXDRState *xdr, JSObject **objp);
  478.  
  479. extern uint32
  480. js_Mark(JSContext *cx, JSObject *obj, void *arg);
  481.  
  482. extern void
  483. js_Clear(JSContext *cx, JSObject *obj);
  484.  
  485. extern jsval
  486. js_GetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot);
  487.  
  488. extern JSBool
  489. js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v);
  490.  
  491. extern JSObject *
  492. js_CheckScopeChainValidity(JSContext *cx, JSObject *scopeobj, const char *caller);
  493.  
  494. extern JSBool
  495. js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj,
  496.                          JSPrincipals *principals, const char *caller);
  497. JS_END_EXTERN_C
  498.  
  499. #endif /* jsobj_h___ */
  500.